home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 3 / BBS in a box - Trilogy III.iso / Files / Prog / B-C / C++ FAQ Reference 1.0 / C++ FAQ Reference 1.0.rsrc / TEXT_733.txt < prev    next >
Encoding:
Text File  |  1993-06-30  |  864 b   |  6 lines

  1. What if I forget the '[]' when 'delete'ing array allocated via 'new X[n]'?
  2. A: Life as we know it suddenly comes to a catastrophic end.
  3.  
  4. It is the programmer's --not the compiler's-- responsibility to get the connection between new[] and delete[] correct.  If you get it wrong, neither a compile-time nor a run-time error message will be generated by the compiler.
  5.  
  6. Depending on the implementation, the results *may* be harmless if the class whose objects are being 'delete'd has no destructor, but this is implementation dependent.  If the class *does* have a destructor, only the first object in the array (the one at 'ptr[0]') will be destructed properly; the rest will simply be abandoned.  If the destructor releases memory, this will be a memory leak; if it closes files or unlocks semaphores or other environmental actions, system integrity may be fractured.